﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>{$meta_title}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="__STATIC__/common/libs/layui-master/dist/css/layui.css" media="all">
	<link rel="stylesheet" href="__STATIC__/admin/css/login.css" media="all" />
</head>
<body>
	<div class="login" style="height: 279px;">
		<h1>管理登录</h1>
		<form class="layui-form" method="post" action="{:url('')}" id="form">
			<input type="hidden" name="__token__" value="{:token()}" />
			<div class="layui-form-item">
				<input class="layui-input" name="name" placeholder="用户名" lay-verify="required" type="text" autocomplete="off">
			</div>
			<div class="layui-form-item">
				<input class="layui-input" name="password" placeholder="密码" lay-verify="required" type="password" autocomplete="off">
			</div>
			<div class="layui-form-item form_code">
				<input class="layui-input" name="verify" placeholder="验证码" lay-verify="required" type="text" autocomplete="off">
				<div class="code"><img src="{:url('api/Captcha/getVerify',['math'=>true])}" onclick="this.src=this.src+'?'+Math.random()" align="absmiddle" title="点击换一张" alt="验证码"></div>
			</div>
			<div class="layui-form-item" pane="">
				<input type="checkbox" name="rememberMe" value="1" lay-skin="primary" title="记住密码" checked="">
				<div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary">
					<span>记住密码</span><i class="layui-icon layui-icon-ok"></i>
				</div>
			</div>
			<button class="layui-btn login_btn" type="button" onclick="login();" >登录</button>
		</form>
	</div>
	<script src="__STATIC__/common/js/jquery.min.js"></script>
	<script src="__STATIC__/common/libs/layer/layer.js"></script>
	<script src="__STATIC__/common/js/login.js"></script>
	<script src="__STATIC__/common/libs/layui-master/dist/layui.js" charset="utf-8"></script>
	<script src="__STATIC__/common/libs/layuimini/js/lay-config.js" charset="utf-8"></script>
	<script type="text/javascript">
		layui.use(['form'], function () {
			var form = layui.form;
		});
		/* 登录 开始 */
		function login(){
			var form = $("#form");
			var url = form.attr('action');
			if(!$("input[name='verify']").val()){
				layer.msg('请输入验证码', {icon: 2,time:1500});
				return false;
			}
			if(!$("input[name='name']").val()){
				layer.msg('请输入用户名', {icon: 2,time:1500});
				return false;
			}
			if(!$("input[name='password']").val()){
				layer.msg('请输入密码', {icon: 2,time:1500});
				return false;
			}
			var query = form.serialize();
			$.post(url,query,function(data){
				if(data.code==0){
					layer.msg(data.msg, {icon: 2,time:1500});
					setTimeout(function(){
						if(data.url){
							location.href=data.url;
						}
					},1500);
				}else{
					layer.msg(data.msg, {icon: 1,time:1500});
					setTimeout(function(){
						if(data.url){
							location.href=data.url;
						}
					},1500);
				}
			},"JSON");
		}
		// 回车登录
		$(document).keyup(function(e) {
			if (e.keyCode === 13) {
				login();
				return false;
			}
		});
		/* 登录 结束 */
	</script>
</body>
</html>